<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>未读消息</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			$("#checkAll").click(function () {
				$("input[name='id']:checkbox").prop("checked", this.checked);            
			});
		});
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
        	return false;
        }
		//批量阅读
		function batchExamine(){
			var delList = [];
			$("#contentTable .checkbox-hook:checked").each(function (){
				delList.push($(this).val());
			})
			if(delList.length == 0){
				$.jBox.tip('请至少选择一条数据阅读。', 'error');
			}else{
				$.jBox.confirm("您确认已阅读"+delList.length+"条信息吗？", "提示信息", submit, { buttons: { '确定': true, '取消': false} });
				$("#ids").val(delList);
			}
		}
		var submit = function (v, h, f) {
		    if (v == true){
		    	loading('提交中，请稍等...');
	    		$("#examineForm").attr("action", "${ctx}/news/news/read");
	    		$("#examineForm").submit();
		    }
		    return true;
		};
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li class="active"><a href="${ctx}/news/news/unread_news_list">未读消息列表</a></li>
	</ul>
	<form:form id="searchForm" modelAttribute="news" action="${ctx}/news/news/unread_news_list" method="post">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
	</form:form>
	<div class="breadcrumb">
		<shiro:hasPermission name="news:news:read">
			<form id="examineForm" method="post" style="display:inline-block;margin: 0 0 0px">
				<input type="hidden" id="ids" name="ids" value=""/>
		  		<a class="btn btn-danger" type="button" onclick="batchExamine()" ><i class="icon-pencil"></i>&nbsp;已阅读</a>
		  	</form>
	  	</shiro:hasPermission>
	 </div>
	<sys:message content="${message}"/>
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead>
			<tr>
				<th><input type="checkbox" id="checkAll"/></th>
				<th>接收用户</th>
				<th>是否已读</th>
				<th>阅读时间</th>
				<th>标题</th>
				<th>内容</th>
				<th>消息类型</th>
				<th>录入时间</th>
			</tr>
		</thead>
		<tbody>
		<c:choose>
			<c:when test="${not empty page.list}">
				<c:forEach items="${page.list}" var="news">
					<tr>
						<td><input class="checkbox-hook" type="checkbox" name="id" value="${news.id}"/></td>
						<td>
							${news.acceptUserName}
						</td>
						<td>
							${fns:getDictLabel(news.seeState, 'seeState', '')}
						</td>
						<td>
							<fmt:formatDate value="${news.seeDateTime}" pattern="yyyy-MM-dd HH:mm:ss"/>
						</td>
						<td>
							${news.title}
						</td>
						<td>
							${news.count}
						</td>
						<td>
							${fns:getDictLabel(news.seeType, 'seeType', '')}
						</td>
						<td>
							<fmt:formatDate value="${news.createDate}" pattern="yyyy-MM-dd"/>
						</td>
					</tr>
				</c:forEach>
			</c:when>
			<c:otherwise>
				<tr>
					<td colspan="9" style="text-align: center;font-size:17px; font-family:SimHei">未查询到数据...</td>
				</tr>
			</c:otherwise>
			</c:choose>
		</tbody>
	</table>
	<div class="pagination">${page}</div>
</body>
</html>